$(function () {
    // 移动适配
    mobileMatvhing();
    $(window).resize(function() {
        mobileMatvhing();
    });
    function mobileMatvhing(){
        var html = document.getElementById('html');
        var phoneWidth = document.documentElement.clientWidth;
        html.style.fontSize = phoneWidth*100/750 + 'px';
    }
    //页面返回上一级
    $(".back").bind("click",function () {
        window.history.back();
    });
    //点击蒙版空白关闭
    $(".maskContain").bind("click",function(event){
        if(event.target.className=="maskContain"){
            closeMask();
            if(window.location.href.indexOf("address")>-1){
                $(".layui-layer-shade").css("opacity","0.7");
            }
        }
    });
});
// 关闭弹窗函数
function closeMask() {
    $('.maskContain').hide();
    $("body").removeClass("scrollPre");
}
// 验证码倒计时
function invokeSettime(obj){
    var countdown=60;
    settime(obj);
    function settime(obj) {
        if (countdown == 0) {
            $(obj).attr("disabled",false);
            $(obj).text("获取验证码");
            $(obj).css('color','#333');
            countdown = 60;
            return;
        } else {
            $(obj).attr("disabled",true);
            $(obj).text("重新发送(" + countdown + ")");
            $(obj).css('color','#999');
            countdown--;
        }
        setTimeout(function() {
                settime(obj) }
            ,1000)
    }
}
//点击按钮触发倒计时
function getCode(event) {
    var id=$(event.target).attr('id');
    new invokeSettime("#"+id);
}
//获取url参数
function GetQueryString(name){
    var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
    var r = window.location.search.substr(1).match(reg);
    if(r!=null)return  unescape(r[2]); return null;
}
